package com.jonychen.swagger2demo.controller;

import com.jonychen.swagger2demo.common.config.extend.ApiError;
import com.jonychen.swagger2demo.common.controller.BaseController;
import com.jonychen.swagger2demo.common.entity.vo.LoginParam;
import com.jonychen.swagger2demo.common.enums.CodeEnum;
import io.swagger.annotations.*;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

/**
 * @Description:活动信息管理类
 * @Author: kui.chen@100credit.com
 * @Date: 2019/9/7 10:19
 */
@RestController
@RequestMapping(value = "/activity",produces = MediaType.APPLICATION_JSON_VALUE)
@Api(value = "/activity",tags = "activity api", description = "活动信息管理类 - 包括增、删、改、查和其他管理操作")
public class ActivityController extends BaseController {


    @PostMapping("/login")
    @ApiOperation(value = "用户登录", notes = "根据用户名和密码登录，返回token")
    @ApiImplicitParam(name = "token",value = "",required = false,paramType ="header",dataType = "String",access = "hidden")
    @ApiResponses({
            @io.swagger.annotations.ApiResponse(code = 200, message = "登录成功", response = ApiError.class),
            @io.swagger.annotations.ApiResponse(code = 4014, message = "用户不存在", response = ApiError.class),
            @io.swagger.annotations.ApiResponse(code = 4018, message = "账号密码错误", response = ApiError.class),
            @io.swagger.annotations.ApiResponse(code = 4015, message = "账号被冻结,请联系管理员", response = ApiError.class)
    })
    public void login(@ModelAttribute LoginParam param) {
        //校验参数
       /* BeanValidator.check(param);
        String token = adminService.login(param);
        HashMap map = Maps.newHashMap();
        map.put("token", token);*/
    }



    @ApiOperation(value = "新增活动接口", notes = "根据传进来的参数创建一个活动")
    @RequestMapping(value = "/{type}", method = {RequestMethod.GET, RequestMethod.POST}, produces = "text/plain;charset=UTF-8")
    public String add(
            @ApiParam(name = "type", required = true, value = "哪个模块内的搜索")
            @PathVariable("type") String type,
            @ApiParam(name = "query", required = true, value = "搜索关键字")
            @RequestParam(name = "query", required = true) String query,
            @ApiParam(name = "size", required = false, value = "每一模块中的最大返回结果数", defaultValue = "3")
            @RequestParam(name = "size", required = false, defaultValue = "3") String size) {
        String data="";
        //data=searchService.searchResult(type, query, size);
        return  respJson(CodeEnum.SUCC,data);
    }

    @ApiOperation(value = "根据附件ID获取附件")
    @ApiImplicitParams({
            @ApiImplicitParam(required = true, name = "certID", value = "证书ID", paramType = "query", dataType = "string"),
            @ApiImplicitParam(required = true, name = "attachId", value = "附件ID", paramType = "query", dataType = "string")
    })
    @ApiResponses({@ApiResponse(code = 200, message = "正确返回" ,response = ApiError.class)})
    @RequestMapping(value = "/external/downloadAttachById",method = RequestMethod.GET)
    public void downloadAttachById(){
       //业务逻辑
    }

}
